package com.situ.mall.controller.back;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.mall.entity.Category;
import com.situ.mall.entity.CategoryCount;
import com.situ.mall.entity.Result;
import com.situ.mall.service.ICategoryService;

@Controller
@RequestMapping("/category")
public class CategoryController {
	@Autowired
	private ICategoryService categoryService;
	
	@RequestMapping("/selectSecondCategoryByTopCategoryId.action")
	@ResponseBody
	public Result selectSecondCategoryByTopCategoryId(Integer topCategoryId) {
		List<Category> secondCategoryList = categoryService.selectSecondCategoryByTopCategoryId(topCategoryId);
		if (secondCategoryList == null || secondCategoryList.size() == 0) {
			return Result.error("二级分类数据查找失败");
		} else {
			return Result.success("", secondCategoryList);
		}
	}
	
	@RequestMapping("/getCategoryCountPage.action")
	public String getCategoryCountPage() {
		return "category_count";
	}
	
	@RequestMapping("/getCategoryCount.action")
	@ResponseBody
	public Result getCategoryCount() {
		System.out.println("CategoryController.getCategoryCount()");
		List<CategoryCount> list = categoryService.getCategoryCount();
		return Result.success("", list);
	}
}
